<?php
//filename : m_penilai_dp3.php

require_once APPPATH.'models/gnc_db_mysql'.EXT;

class M_PENILAI_DP3 extends Gnc_db_mysql {
	protected $data_source	= 'dpt_m_penilai';

	function select_query($var_select=NULL,$var_where=NULL,$order_by=NULL) //select, where in format array or string 'cond="value"' order by one value
		{
			if($var_select != NULL){
				if (is_array($val_select))
				{
					$this->db->select(implode(',',$field));
				}else{
					if(!$var_select)
					{
						$this->db->select($var_select);
					}
				}
			}

			if($var_where != NULL)
			{
				if (is_array($var_where)){
					foreach($var_where as $key=>$val){
						$this->db->where($key,$val);
					}
				}else{
					$this->db->where("`".substr($var_where,0,strpos($var_where,"="))."`",substr($var_where,strpos($var_where,"=")+1));
				}
			}

			if($order_by != NULL){
				$this->db->order_by($order_by);
			}

			$query = $this->db->get($this->data_source);
			return $query->result();
		}

	function select_karakteristik($nip)
	{
		$sql = "SELECT * FROM dpt_m_penilai as DMP WHERE (nip_penilai_1 = ? or nip_penilai_2 = ? or nip_penilai_3 = ?) and (DMP.nip NOT IN(SELECT nip FROM dpt_h_dp3 WHERE nip_penilai = ? AND STATUS = 'OK'))";
		$query = $this->db->query($sql, array($nip, $nip, $nip, $nip));

		return $query->result();
	}

	function isPenilai_1($nip, $nip_login)
	{
		$sql = "SELECT * FROM dpt_m_penilai WHERE nip= ? and nip_penilai_1 = ?";
		$query = $this->db->query($sql, array($nip, $nip_login));
		if ($query->num_rows() > 0)
			return true;
		else
			return false;
	}

	function isPenilai_2($nip, $nip_login)
	{
		$sql = "SELECT * FROM dpt_m_penilai WHERE nip= ? and nip_penilai_2 = ?";
		$query = $this->db->query($sql, array($nip, $nip_login));
		if ($query->num_rows() > 0)
			return true;
		else
			return false;
	}

	function isPenilai_3($nip, $nip_login)
	{
		$sql = "SELECT * FROM dpt_m_penilai WHERE nip= ? and nip_penilai_3 = ?";
		$query = $this->db->query($sql, array($nip, $nip_login));	
		if ($query->num_rows() > 0)
			return true;
		else
			return false;
	}

	function isDinilai($nip, $periode)
	{
		$sql = "SELECT * FROM dpt_m_penilai WHERE nip= ? and periode_dp3 = ?";
		$query = $this->db->query($sql, array($nip,$periode));	
		if ($query->num_rows() > 0)
			return true;
		else
			return false;
	}
}

?>
